import request from "@/utils/request";

// 从配置中获取业务的地址
// import { baseUrlConfig } from '@/config/config'
// const basePath = baseUrlConfig.businessBaseUrl
import { baseUrlConfig } from "@/config/config";
const basePath = baseUrlConfig.processBaseUrl;

export interface PageListType {
  pageNum?: number;
  pageSize?: number;
  condition: {
    columns: string;
    endTime: string;
    eventReportId: 0;
    id: 0;
    startTime: string;
    type: string;
  };
}

export interface ViewEventType {
  eventReportId: string;
}

export interface eventLevelType {
  startTime: string;
  endTime: string;
}
// 获取分页列表
export const problemPageList: (data: PageListType) => Promise<[]> = (
  data: PageListType
) => {
  return request({
    // url: basePath + "/event/analysis/find/page",
    url: basePath + "/event/analysis/findPageList",
    method: "post",
    data: {
      pageSize: data.pageSize,
      pageNum: data.pageNum,
      condition: {
        eventOccurStartTime: data.condition.startTime,
        eventOccurEndTime: data.condition.endTime,
      },
    },
  });
};
// 查看
export const viewEvent: (data: ViewEventType) => Promise<[]> = (
  data: ViewEventType
) => {
  return request({
    url: basePath + "/event/analysis/queryAnalysis",
    method: "post",
    data: {
      eventReportId: data.eventReportId,
    },
  });
};

// 事件等级统计
export const eventLevel: (data: eventLevelType) => Promise<[]> = (
  data: eventLevelType
) => {
  return request({
    url: basePath + "/event/analysis/queryEventLeaveData",
    method: "post",
    data: {
      eventOccurStartTime: data.startTime,
      eventOccurEndTime: data.endTime,
    },
  });
};

// 事件类型统计
export const eventType: (data: eventLevelType) => Promise<[]> = (
  data: eventLevelType
) => {
  return request({
    url: basePath + "/event/analysis/queryEventTypeData",
    method: "post",
    data: {
      eventOccurStartTime: data.startTime,
      eventOccurEndTime: data.endTime,
    },
  });
};

// 事件发生频段统计
export const eventFrequencyBand: (data: eventLevelType) => Promise<[]> = (
  data: eventLevelType
) => {
  return request({
    url: basePath + "/event/analysis/queryEventOccurTimeData",
    method: "post",
    data: {
      eventOccurStartTime: data.startTime,
      eventOccurEndTime: data.endTime,
    },
  });
};
